package IU;

import Controladores.CtrlAMBOperario;
import Entidades.Localidad;
import Entidades.Pais;
import Entidades.Provincia;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import utiles.Validador;
import Controladores.CtrlLocalidad;
import Controladores.CtrlPais;
import Controladores.CtrlProveedor;
import Controladores.CtrlProvincia;
import Entidades.Estadooperario;
import Entidades.Operario;
import Entidades.Proveedor;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Date;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author  
 * 
 * 
 */
public class ABMProveedor extends javax.swing.JFrame {

    private String razon, nroPrevSocial, nroIB, nroInv, apellido, nombre, cuit, direccion, codigopostal, fechaAlta, fechaBaja,operario;
    private String pais;
    private String provincia;
    private String localidad;
    String telefono1;
    String telefono2;
    int telef1;
    int telef2;
    Proveedor proveedor;
    Operario oper;
    TablaPersonalizada tableModel;
    private List lista, listap;
    CtrlProveedor controladorprovee;
    CtrlPais controladorpais;
    CtrlProvincia controladorprov;
    CtrlLocalidad controladorlocal;
    CtrlAMBOperario controladoroperario;
    Proveedor o;
    Validador validador;
    private List listaep, listatd, listaprov, listapais, listaloc, listao, listac;
    //acá ver si puedo hacer lo mismo con pais provincia traer la collection de provincia
    Collection<Localidad> localidadesCollection = new ArrayList<Localidad>();
    Estadooperario miestado = null;
    private int fila;
   
    private List<Proveedor> listapbaja;

    public ABMProveedor(String operarios) {
        initComponents();
        operario = operarios;
        jTextFieldUsuario2.setText(operario);
//        jTextFieldUsuario4.setText(operario);
  //      jTextFieldUsuario5.setText(operario);
        controladorpais = new CtrlPais();
        controladorprov = new CtrlProvincia();
        controladorlocal = new CtrlLocalidad();
        controladorprovee = new CtrlProveedor();
        controladoroperario = new CtrlAMBOperario();
        jPanel4.setVisible(false);
        jPanel5.setVerifyInputWhenFocusTarget(false);
        //alta

       
        //fin alta
        //consultar
        cargarComboRazon();
        //fin consultar
        //modificar
        cargarTabla();//ojo que está cargando el primero
        cargarComboPaises();
        cargarComboPaises1();

        jComboBoxpais.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo2((String) jComboBoxpais.getSelectedItem());
			}



		});

rellenaCombo2((String) jComboBoxpais.getSelectedItem());

jComboBoxprovincia.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo3((String) jComboBoxprovincia.getSelectedItem());
			}

           		});
rellenaCombo3((String) jComboBoxprovincia.getSelectedItem());

jComboBoxlocalidad.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo4((String) jComboBoxlocalidad.getSelectedItem());
			}



           		});
rellenaCombo4((String) jComboBoxlocalidad.getSelectedItem());


jComboBoxpais1.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo5((String) jComboBoxpais1.getSelectedItem());
			}



		});

rellenaCombo5((String) jComboBoxpais1.getSelectedItem());

jComboBoxprovincia1.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo6((String) jComboBoxprovincia1.getSelectedItem());
			}

           		});
rellenaCombo6((String) jComboBoxprovincia1.getSelectedItem());

jComboBoxlocalidad1.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				rellenaCombo7((String) jComboBoxlocalidad1.getSelectedItem());
			}



           		});
rellenaCombo7((String) jComboBoxlocalidad1.getSelectedItem());
    

    
}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButtonGuardar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldapellido = new javax.swing.JTextField();
        jTextFieldnombre = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldrazon = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldcuit = new javax.swing.JTextField();
        jTextFielddireccion = new javax.swing.JTextField();
        jComboBoxpais = new javax.swing.JComboBox();
        jComboBoxlocalidad = new javax.swing.JComboBox();
        jTextFieldtelefono1 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jTextFieldtelefono2 = new javax.swing.JTextField();
        jTextFieldcodigoPostal = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jComboBoxprovincia = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldcajavPrev = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldnroInv = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldnroIB = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableProveedores = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldapellido1 = new javax.swing.JTextField();
        jTextFieldnombre1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jTextFieldnroInv1 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldcuit1 = new javax.swing.JTextField();
        jTextFielddireccion1 = new javax.swing.JTextField();
        jComboBoxpais1 = new javax.swing.JComboBox();
        jComboBoxlocalidad1 = new javax.swing.JComboBox();
        jTextFieldtelefono3 = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jTextFieldtelefono4 = new javax.swing.JTextField();
        jTextFieldcodigoPostal1 = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jComboBoxprovincia1 = new javax.swing.JComboBox();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jTextFieldcajaPrevision1 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldrazon1 = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jTextFieldnroIB1 = new javax.swing.JTextField();
        modificar = new javax.swing.JButton();
        eliminar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        ButtBuscar = new javax.swing.JPanel();
        jTextFieldNombreListar = new javax.swing.JTextField();
        jLabelDniCon = new javax.swing.JLabel();
        jLabelTelCon = new javax.swing.JLabel();
        jTextFielCuit = new javax.swing.JTextField();
        jButtonBuscarCon = new javax.swing.JButton();
        jLabelDireccionCon = new javax.swing.JLabel();
        jTextFieldtelefono = new javax.swing.JTextField();
        jLabelApellidoCon = new javax.swing.JLabel();
        jComboBoxRazon = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jTextFielapellido = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        jTextFieldFechaAlta = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTablePB = new javax.swing.JTable();
        jButtonSalir = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jTextFieldUsuario2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gestionar Proveedores - Sistema Gestor de Pesaje para Bodegas");

        jTabbedPane1.setForeground(new java.awt.Color(102, 0, 102));
        jTabbedPane1.setFont(new java.awt.Font("Segoe UI", 3, 12));

        jButtonGuardar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonGuardar.setForeground(new java.awt.Color(102, 0, 102));
        jButtonGuardar.setText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel4.setText("Apellido:");

        jTextFieldapellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldnombre.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel2.setText("Nombre:");

        jLabel12.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel12.setText("Razón Social:");

        jTextFieldrazon.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel1.setText("Cuit");

        jTextFieldcuit.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFielddireccion.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxpais.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxlocalidad.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldtelefono1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel15.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel15.setText("Telefono 2:");

        jTextFieldtelefono2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldcodigoPostal.setEditable(false);
        jTextFieldcodigoPostal.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel16.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel16.setText("Código Postal:");

        jLabel17.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel17.setText("Provincia:");

        jComboBoxprovincia.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel18.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel18.setText("Dirección:");

        jLabel19.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel19.setText("Pais: ");

        jLabel20.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel20.setText("Localidad:");

        jLabel21.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel21.setText("Telefono 1: ");

        jLabel8.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel8.setText("Caja Previsión Social:");

        jTextFieldcajavPrev.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel9.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel9.setText("Número INV:");

        jTextFieldnroInv.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel10.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel10.setText("Nro I Brutos:");

        jTextFieldnroIB.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel31.setForeground(new java.awt.Color(0, 102, 102));
        jLabel31.setText("* Todos los campos son obligatorios, si no posee telefono ingrese 0 ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel31)
                    .addComponent(jLabel10)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel19)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jTextFieldcuit, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel8))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jComboBoxpais, 0, 180, Short.MAX_VALUE)
                                            .addComponent(jTextFieldtelefono1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                                            .addComponent(jComboBoxlocalidad, 0, 180, Short.MAX_VALUE)
                                            .addComponent(jTextFieldnroIB))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel9)
                                            .addComponent(jLabel17)
                                            .addComponent(jLabel16)
                                            .addComponent(jLabel15))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldnroInv, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldtelefono2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldcodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxprovincia, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldcajavPrev, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.Alignment.TRAILING)))
                            .addComponent(jTextFielddireccion)
                            .addComponent(jTextFieldnombre)
                            .addComponent(jTextFieldapellido)
                            .addComponent(jTextFieldrazon))))
                .addContainerGap(449, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jTextFieldrazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldcuit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8)
                        .addComponent(jTextFieldcajavPrev, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel1))
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFielddireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldnroIB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldnroInv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxpais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(jLabel17)
                    .addComponent(jComboBoxprovincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jComboBoxlocalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldcodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel21)
                        .addComponent(jTextFieldtelefono1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel15)
                        .addComponent(jTextFieldtelefono2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(50, 50, 50)
                .addComponent(jButtonGuardar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel31)
                .addGap(110, 110, 110))
        );

        jTabbedPane1.addTab("Alta Proveedor", jPanel1);

        jScrollPane2.setAutoscrolls(true);

        jTableProveedores.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableProveedores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Apellido", "Nombre", "Tipo Documento", "Nro Documento", "Telefono 1", "Pais", "Provincia", "Localidadl"
            }
        ));
        jTableProveedores.setAutoscrolls(false);
        jTableProveedores.setFillsViewportHeight(true);
        jTableProveedores.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableProveedores.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableProveedores.setRowHeight(14);
        jTableProveedores.getTableHeader().setResizingAllowed(false);
        jTableProveedores.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableProveedoresMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTableProveedores);

        jScrollPane2.setViewportView(jScrollPane3);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del Proveedor:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel5.setText("Apellido:");

        jTextFieldapellido1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextFieldapellido1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldapellido1ActionPerformed(evt);
            }
        });

        jTextFieldnombre1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel3.setText("Nombre:");

        jLabel11.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel11.setText("Caja Previsión:");

        jLabel13.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel13.setText("Número Inv:");

        jTextFieldnroInv1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel6.setText("Cuit:");

        jTextFieldcuit1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFielddireccion1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxpais1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxlocalidad1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldtelefono3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel23.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel23.setText("Telefono 2:");

        jTextFieldtelefono4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldcodigoPostal1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel24.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel24.setText("Código Postal:");

        jLabel25.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel25.setText("Provincia:");

        jComboBoxprovincia1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel26.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel26.setText("Dirección:");

        jLabel27.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel27.setText("Pais: ");

        jLabel28.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel28.setText("Localidad:");

        jLabel29.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel29.setText("Telefono 1: ");

        jTextFieldcajaPrevision1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel14.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel14.setText("Razón Social:");

        jTextFieldrazon1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel22.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel22.setText("Número Ingresos Brutos:");

        jTextFieldnroIB1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        modificar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        modificar.setForeground(new java.awt.Color(102, 0, 102));
        modificar.setText("Modificar");
        modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarActionPerformed(evt);
            }
        });

        eliminar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        eliminar.setForeground(new java.awt.Color(102, 0, 102));
        eliminar.setText("Eliminar");
        eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel27)
                            .addComponent(jLabel28)
                            .addComponent(jLabel29))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldtelefono3, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jComboBoxlocalidad1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jComboBoxpais1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(90, 90, 90)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel25)
                            .addComponent(jLabel24)
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldtelefono4, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                            .addComponent(jTextFieldcodigoPostal1)
                            .addComponent(jComboBoxprovincia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldnombre1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                            .addComponent(jTextFieldrazon1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                            .addComponent(jTextFieldapellido1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel6)
                            .addComponent(jLabel26))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFielddireccion1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jTextFieldcuit1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldnroIB1, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jTextFieldcajaPrevision1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                                .addComponent(jLabel13)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldnroInv1, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(31, 31, 31)
                .addComponent(modificar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(eliminar)
                .addGap(31, 31, 31))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(258, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(eliminar)
                    .addComponent(modificar))
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTextFieldrazon1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldapellido1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldnombre1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextFieldnroInv1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jTextFieldcajaPrevision1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel22)
                    .addComponent(jTextFieldnroIB1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldcuit1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(jTextFielddireccion1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(jComboBoxpais1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxprovincia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(jTextFieldcodigoPostal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24)
                    .addComponent(jComboBoxlocalidad1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(jLabel23)
                    .addComponent(jTextFieldtelefono4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldtelefono3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19))
        );

        jButton1.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButton1.setForeground(new java.awt.Color(102, 0, 102));
        jButton1.setText("Modificar Datos");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 886, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(19, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(293, 293, 293))
        );

        jTabbedPane1.addTab("Modificar/Eliminar", jPanel2);

        ButtBuscar.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del Proveedor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldNombreListar.setEditable(false);
        jTextFieldNombreListar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabelDniCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDniCon.setText("Nombre:");

        jLabelTelCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelTelCon.setText("Cuit:");

        jTextFielCuit.setEditable(false);
        jTextFielCuit.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jButtonBuscarCon.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarCon.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarCon.setMnemonic('B');
        jButtonBuscarCon.setText("Buscar");
        jButtonBuscarCon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarConActionPerformed(evt);
            }
        });

        jLabelDireccionCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDireccionCon.setText("Telefono:");

        jTextFieldtelefono.setEditable(false);
        jTextFieldtelefono.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabelApellidoCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelApellidoCon.setText("Razón Social:");

        jComboBoxRazon.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jComboBoxRazon.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jComboBoxRazonMousePressed(evt);
            }
        });
        jComboBoxRazon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxRazonActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel7.setText("Apellido:");

        jTextFielapellido.setEditable(false);
        jTextFielapellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel30.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel30.setText("Fecha de alta:");

        jTextFieldFechaAlta.setEditable(false);
        jTextFieldFechaAlta.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout ButtBuscarLayout = new javax.swing.GroupLayout(ButtBuscar);
        ButtBuscar.setLayout(ButtBuscarLayout);
        ButtBuscarLayout.setHorizontalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtBuscarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelDniCon)
                    .addComponent(jLabelApellidoCon)
                    .addComponent(jLabel7)
                    .addComponent(jLabelTelCon)
                    .addComponent(jLabelDireccionCon)
                    .addComponent(jLabel30))
                .addGap(28, 28, 28)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldtelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addComponent(jTextFielCuit, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addComponent(jTextFielapellido, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addComponent(jTextFieldNombreListar, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addComponent(jComboBoxRazon, javax.swing.GroupLayout.Alignment.TRAILING, 0, 330, Short.MAX_VALUE)
                    .addComponent(jTextFieldFechaAlta, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE))
                .addGap(28, 28, 28)
                .addComponent(jButtonBuscarCon)
                .addGap(74, 74, 74))
        );
        ButtBuscarLayout.setVerticalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtBuscarLayout.createSequentialGroup()
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidoCon)
                    .addComponent(jComboBoxRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBuscarCon))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFielapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDniCon)
                    .addComponent(jTextFieldNombreListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTelCon)
                    .addComponent(jTextFielCuit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDireccionCon)
                    .addComponent(jTextFieldtelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldFechaAlta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel30))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        jButton2.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButton2.setForeground(new java.awt.Color(102, 0, 102));
        jButton2.setText("Consultar Bajas");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Bajas de Proveedores", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTablePB.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTablePB);

        jScrollPane4.setViewportView(jScrollPane1);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(97, Short.MAX_VALUE)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(70, 70, 70))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(211, 211, 211)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButton2)
                        .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(230, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Listar Proveedor", jPanel3);

        jButtonSalir.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonSalir.setForeground(new java.awt.Color(102, 0, 102));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Usuario Registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldUsuario2.setEditable(false);
        jTextFieldUsuario2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1079, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(136, 136, 136)
                        .addComponent(jButtonSalir))
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 354, Short.MAX_VALUE)
                .addComponent(jButtonSalir)
                .addGap(112, 112, 112))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1317)/2, (screenSize.height-634)/2, 1317, 634);
    }// </editor-fold>//GEN-END:initComponents

    private void refresh() {
        jTextFieldapellido.setText("");
        jTextFieldnombre.setText("");
        jTextFieldrazon.setText("");
        jTextFieldcuit.setText("");
        jTextFielddireccion.setText("");
        jTextFieldcodigoPostal.setText("");
        jTextFieldtelefono1.setText("");
        jTextFieldtelefono2.setText("");
        jTextFieldcajavPrev.setText("");
        jTextFieldnroInv.setText("");
    }

private void jTableProveedoresMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableProveedoresMouseClicked
    cargarCampos();
}//GEN-LAST:event_jTableProveedoresMouseClicked

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jButtonSalirActionPerformed

////////////////////////////ALTA OPERARIO////////////////////////////
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
    boolean ver = false;

    Pais paisper = null;
    Provincia provinciaper = null;
    Localidad localidadper = null;
    razon = jTextFieldrazon.getText();
    nombre = jTextFieldnombre.getText();
    apellido = jTextFieldapellido.getText();
    direccion = jTextFielddireccion.getText();
    nroPrevSocial = jTextFieldcajavPrev.getText();
    nroIB = jTextFieldnroIB.getText();
    nroInv = jTextFieldnroInv.getText();
    cuit = jTextFieldcuit.getText();

    pais = jComboBoxpais.getSelectedItem().toString();
    try {
        paisper = controladorpais.buscarPaisNombre(pais);
    } catch (Exception e) {
    }

    provincia = jComboBoxprovincia.getSelectedItem().toString();
    try {
        provinciaper = controladorprov.buscarProvinciaNombre(provincia);
    } catch (Exception e) {
    }

    localidad = jComboBoxlocalidad.getSelectedItem().toString();
    try {
        localidadper = controladorlocal.buscarLocalidadNombre(localidad);
    } catch (Exception e) {
    }

    codigopostal = jTextFieldcodigoPostal.getText();
//////////////////////////PARA INCLUIR LA FECHA ACTUAL COMO FECHA DE ALTA ////////////
//    Date fechaActual = new Date();
//    String fecha = fechaActual.toString();
//    // String fechaAlta=null;
//    Calendar calendar = Calendar.getInstance();
//
//    int dia = calendar.get(Calendar.DAY_OF_MONTH);   //dia del mes
//    int mescal = calendar.get(Calendar.MONTH);  //mes, de 0 a 11
//
//    //IF MES MENOR QUE 10 CONCATENAR UN CERO ADELANTE
//
//    mescal = mescal + 1;
//
//    int anio = calendar.get(Calendar.YEAR);  //año
//
//    String diacalendar = String.valueOf(dia);
//    String mescalendar = String.valueOf(mescal);
//
//    if (mescal < 10) {
//        mescalendar = "0" + String.valueOf(mescal);
//        System.out.println("mescalendar es:" + mescal);
//    }
//
//    String aniocalendar = String.valueOf(anio);
//    fechaAlta = diacalendar + "/" + mescalendar + "/" + aniocalendar;
    fechaAlta = Validador.getInstance().obtenerFechaSistema();
    System.out.println("La fecha de hoy es: " + fechaAlta);
    ////////////////////////////////////////////////////////////////////////////////////

    String tel1 = jTextFieldtelefono1.getText();
    String tel2 = jTextFieldtelefono2.getText();
    telefono1 = jTextFieldtelefono1.getText();
    telefono2 = jTextFieldtelefono2.getText();
    telef1 = Integer.parseInt(telefono1);
    telef2 = Integer.parseInt(telefono2);
    Date f = new Date();
    int dia= f.getDay();
    int mes= f.getMonth();
    int año=f.getYear();
    fechaAlta =Validador.getInstance().obtenerFechaSistema();
    fechaBaja = "";
direccion= jTextFielddireccion.getText();

    if (verificar(razon, nroPrevSocial, apellido, nombre, nroIB, nroInv, pais, provincia, localidad, tel1,  direccion) && (verificar(cuit))) {
        //  if (ver == true) {
        System.out.println("dentro del if paso el verificar");

        Proveedor pro = new Proveedor();
        //razon, nroPrevSocial, cuit, apellido, nombre, nroIB, nroInv, paisper, provinciaper, localidadper, telef1, telef2, fechaAlta, fechaBaja, direccion

        pro.setRazonSocialProveedor(razon);
        pro.setCajaPrevSocialProveedor(nroPrevSocial);
        pro.setApellidoProveedor(apellido);
        pro.setCuitProveedor(cuit);
        pro.setNombreProveedor(nombre);
        pro.setNumeroIngresosBrutosProveedor(nroIB);
        pro.setNumeroInvProveedor(nroInv);
        pro.setPais(paisper);
        pro.setTelefono1(telef1);
        pro.setTelefono2(telef2);
        pro.setFechaalta(fechaAlta);
        pro.setLocalidad(localidadper);
        pro.setProvincia(provinciaper);
        pro.setDireccionProveedor(direccion);



        System.out.println("prove " + pro.toString());
        controladorprovee.guardarProveedor(pro);


        JOptionPane.showMessageDialog(this, "El proveedor ha sido guardado exitosamente!", "Alta", JOptionPane.INFORMATION_MESSAGE);

        refresh();
        cargarTabla();

    }
}//GEN-LAST:event_jButtonGuardarActionPerformed

    private void cargarComboPaises() {

        try {
            listapais = controladorpais.buscarTodosPais();
        } catch (Exception e) {
        }
        jComboBoxpais.removeAllItems();
        for (int i = 0; i < listapais.size(); i++) {
            Vector fila = new Vector();
            Pais pais = (Pais) listapais.get(i);
            fila.add(pais.getNombrepais());
            jComboBoxpais.addItem(fila.get(0));
        }

    }

    private void cargarComboProvincias(int idpais) {

        Pais estepais = null;
        try {
            estepais = controladorpais.buscarPais_X_idPais(idpais);//el qeu traia seleccionado
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia.removeAllItems();
        for (int j = 0; j < listaprov.size(); j++) {//por cada una de todas las provincias
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(j);
            if (provincia.getPais().equals(estepais)) {
                fila.add(provincia.getNombreprovincia());
                jComboBoxprovincia.addItem(fila.get(0));
            }
        }


    }

    private void cargarComboLocalidades(int idprovincia) {

        Provincia estaprovincia = null;
        try {
            estaprovincia = controladorprov.buscarProvincia_X_idProvincia(idprovincia);
            System.out.println(estaprovincia.getNombreprovincia()+"provincia en localidad");
            listaloc = controladorlocal.buscarTodosLocalidad();
             System.out.println(listaloc+"lista localidades");
        } catch (Exception e) {

           



            //aca larga el javalangnullpointerexception
        }
        jComboBoxlocalidad.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {//para todas las localidades
            Vector fila = new Vector();
            Localidad milocalidad = (Localidad) listaloc.get(i);
            if (milocalidad.getProvincia().equals(estaprovincia)) {
                fila.add(milocalidad.getNombrelocalidad());
                jComboBoxlocalidad.addItem(fila.get(0));
               
            }
        }
    }

    //////////////MODIFICAR OPERARIO/////////////////////////
    private void cargarComboPaises1() {

        try {
            listapais = controladorpais.buscarTodosPais();
        } catch (Exception e) {
        }
        jComboBoxpais1.removeAllItems();
        for (int i = 0; i < listapais.size(); i++) {
            Vector fila = new Vector();
            Pais pais = (Pais) listapais.get(i);
            fila.add(pais.getNombrepais());
            jComboBoxpais1.addItem(fila.get(0));
        }
    }

    private void cargarComboProvincias1() {

        try {
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia1.removeAllItems();
        for (int i = 0; i < listaprov.size(); i++) {
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(i);
            fila.add(provincia.getNombreprovincia());
            jComboBoxprovincia1.addItem(fila.get(0));
        }
    }

    private void cargarComboLocalidades1() {
        try {
            listaloc = controladorlocal.buscarTodosLocalidad();
        } catch (Exception e) {
        }
        jComboBoxlocalidad1.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {
            Vector fila = new Vector();
            Localidad localidad = (Localidad) listaloc.get(i);
            fila.add(localidad.getNombrelocalidad());
          //  jComboBoxlocalidad.addItem(fila.get(0));
            jComboBoxlocalidad1.addItem(fila.get(0));
        }
    }

    private void actualizarCombo(List lista1) {
        jComboBoxRazon.removeAllItems();
        for (int i = 0; i < lista1.size(); i++) {
            Vector fila = new Vector();
            Proveedor proveedor = (Proveedor) lista1.get(i);
            fila.add(proveedor.getCuitProveedor());
            jComboBoxRazon.addItem(fila.get(0));
        }
    }

    public void actualizarDatos(Proveedor proveedorSel) {

        jTextFieldapellido1.setText(proveedorSel.getApellidoProveedor());
        jTextFieldnombre1.setText(proveedorSel.getNombreProveedor());
        jTextFieldcuit1.setText(proveedorSel.getCuitProveedor());
        jTextFieldnroInv1.setText(String.valueOf(proveedorSel.getNumeroInvProveedor()));
        jTextFielddireccion1.setText(proveedorSel.getDireccionProveedor());
        jTextFieldtelefono1.setText(String.valueOf(proveedorSel.getTelefono1()));
        jTextFieldtelefono2.setText(String.valueOf(proveedorSel.getTelefono2()));


    }

private void modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarActionPerformed

    Pais paisper = null;
    Provincia provinciaper = null;
    Localidad localidadper = null;
    boolean ver = false;
    int ind = jTableProveedores.getSelectedRow();
    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Debe seleccionar un Operario para modificar!", "Modificar Operario", JOptionPane.INFORMATION_MESSAGE);
    } else {
        razon = jTextFieldrazon1.getText();
        nombre = jTextFieldnombre1.getText();
        apellido = jTextFieldapellido1.getText();
        direccion = jTextFielddireccion1.getText();
        nroPrevSocial = jTextFieldcajaPrevision1.getText();
        nroIB = jTextFieldnroIB1.getText();
        nroInv = jTextFieldnroInv1.getText();
        cuit = jTextFieldcuit1.getText();

        pais = jComboBoxpais1.getSelectedItem().toString();
        try {
            paisper = controladorpais.buscarPaisNombre(pais);
        } catch (Exception e) {
        }
        provincia = jComboBoxprovincia1.getSelectedItem().toString();
        try {
            provinciaper = controladorprov.buscarProvinciaNombre(provincia);
        } catch (Exception e) {
        }
        localidad = jComboBoxlocalidad1.getSelectedItem().toString();
        try {
            localidadper = controladorlocal.buscarLocalidadNombre(localidad);

        } catch (Exception e) {
        }
        codigopostal = jTextFieldcodigoPostal1.getText();
        ////////////////////
/////////////////////

        String tel3 = jTextFieldtelefono3.getText();
        String tel4 = jTextFieldtelefono4.getText();
        telef1 = Integer.parseInt(tel3);
        telef2 = Integer.parseInt(tel4);

        fechaAlta = ""; //esta fecha no se debería poder modificar
        fechaBaja = "";//esta fecha se da al eliminar


        proveedor = (Proveedor) listao.get(fila);


        //verificar que el cuit no exista para otro proveedor
        if (verificar(razon, nroPrevSocial, apellido, nombre, nroIB, nroInv, pais, provincia, localidad, tel3, direccion) && verificar2(cuit)) {




                proveedor.setApellidoProveedor(apellido);
                proveedor.setNombreProveedor(nombre);
                proveedor.setDireccionProveedor(direccion);
                proveedor.setRazonSocialProveedor(razon);
                proveedor.setNumeroIngresosBrutosProveedor(nroIB);
                proveedor.setNumeroInvProveedor(nroInv);
                proveedor.setCajaPrevSocialProveedor(nroPrevSocial);
                proveedor.setPais(paisper);
                proveedor.setProvincia(provinciaper);
                proveedor.setLocalidad(localidadper);

                proveedor.setTelefono1(telef1);
                proveedor.setTelefono2(telef2);
                proveedor.setCuitProveedor(cuit);
                proveedor.setFechaalta(fechaAlta);
                proveedor.setFechabaja(fechaBaja);

try{
                controladorprovee.modificarProveedor(proveedor);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            JOptionPane.showMessageDialog(this, "La modificación fue realizada de forma Exitosa!", "Modificar proveedor", JOptionPane.INFORMATION_MESSAGE);
            cargarTabla();
        }
    }

}//GEN-LAST:event_modificarActionPerformed

private void jTextFieldapellido1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldapellido1ActionPerformed
}//GEN-LAST:event_jTextFieldapellido1ActionPerformed
    private void cargarCampos() {
       limpiarCampos();
        fila = jTableProveedores.getSelectedRow();

        int nropais;
        int nroprov;
        int nroloc;


        Proveedor proveedor = new Proveedor();
        proveedor = (Proveedor) listao.get(fila);
        jTextFieldrazon1.setText(proveedor.getRazonSocialProveedor());
        jTextFieldapellido1.setText(proveedor.getApellidoProveedor());
        jTextFieldnombre1.setText(proveedor.getNombreProveedor());
        jTextFieldcuit1.setText(proveedor.getCuitProveedor());
        jTextFieldcajaPrevision1.setText(proveedor.getCajaPrevSocialProveedor());
        jTextFieldnroIB1.setText(proveedor.getNumeroIngresosBrutosProveedor());
        jTextFieldnroInv1.setText(String.valueOf(proveedor.getNumeroInvProveedor()));
        jTextFielddireccion1.setText(String.valueOf(proveedor.getDireccionProveedor()));
        jTextFieldtelefono3.setText(String.valueOf(proveedor.getTelefono1()));
        jTextFieldtelefono4.setText(String.valueOf(proveedor.getTelefono2()));


//Pais

     /*   nropais = proveedor.getPais().getIdpais();
        System.out.println("pais"+ nropais);
        String npais = String.valueOf(nropais);
        int nroPais = Integer.parseInt(npais) - 1;
        jComboBoxpais1.setSelectedIndex(nroPais);
//provincia
        nroprov = proveedor.getProvincia().getIdprovincia();
        String nprov = String.valueOf(nroprov);
        int nroProv = Integer.parseInt(nprov) - 1;
        jComboBoxprovincia1.setSelectedIndex(nroProv);
//Localidad
        nroloc = proveedor.getLocalidad().getIdlocalidad();
        String nloc = String.valueOf(nroloc);
        int nroLoc = Integer.parseInt(nloc) - 1;
        jComboBoxlocalidad1.setSelectedIndex(nroLoc);
        jTextFielddireccion1.setText(proveedor.getDireccionProveedor());*/

        jTextFieldcodigoPostal1.setText(proveedor.getLocalidad().getCodigopostal());

        jTextFieldtelefono3.setText(String.valueOf(proveedor.getTelefono1()));

        jTextFieldtelefono4.setText(String.valueOf(proveedor.getTelefono2()));
    }

    private void cargarTabla() {
        String[] encabezados = new String[7];
        encabezados[0] = "Razon Social";
        encabezados[1] = "Apellido";
        encabezados[2] = "Nombre";
        encabezados[3] = "Nro Telefono1";
        encabezados[4] = "Pais";
        encabezados[5] = "Provincia";
        encabezados[6] = "Localidad";

        tableModel = new TablaPersonalizada(encabezados);
        jTableProveedores.setModel(tableModel);

        try {
            listao = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de listao" + listao.size());

            for (int i = 0; i < listao.size(); i++) {
                Vector fila = new Vector();
                Proveedor proveedor = (Proveedor) listao.get(i);
                fila.add(proveedor.getRazonSocialProveedor());
                fila.add(proveedor.getApellidoProveedor());
                fila.add(proveedor.getNombreProveedor());
                fila.add(proveedor.getTelefono1());
                fila.add(proveedor.getPais().getNombrepais());
                fila.add(proveedor.getProvincia().getNombreprovincia());
                fila.add(proveedor.getLocalidad().getNombrelocalidad());

                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void limpiarCampos() {
        jTextFieldapellido1.setText("");
        jTextFieldnombre1.setText("");
        jTextFielddireccion1.setText("");
        jTextFieldcodigoPostal1.setText("");
        jTextFieldcuit1.setText("");
        jTextFieldnroInv1.setText("");
        jTextFieldtelefono3.setText("");
        jTextFieldtelefono4.setText("");

    }

///////////////////ELIMINAR OPERARIO////////////////////////////////////////
private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarActionPerformed
    int ind = jTableProveedores.getSelectedRow();
    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Debe seleccionar un Proveedor para eliminar!", "Elimianr Proveedor", JOptionPane.INFORMATION_MESSAGE);
    } else {
        Proveedor u = (Proveedor) listao.get(ind);
        int rta = JOptionPane.showConfirmDialog(this, "Esta seguro de que desea ELIMINAR el Proveedor:\n Cuit = " + u.getCuitProveedor() + " ?", "Eliminar Proveedor", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
        if (rta == 0) {
            try {
                controladorprovee.eliminarProveedor(u);
                JOptionPane.showMessageDialog(this, "La Eliminación fue realiza", "Eliminar Proveedor", JOptionPane.INFORMATION_MESSAGE);
                cargarTabla();
                limpiarCampos();
            } catch (Exception ex) {
                int rtaa = JOptionPane.showConfirmDialog(this, "Se incluirá esta fecha como fecha de baja del proveedor", "Eliminar Proveedor", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                if (rtaa == 0) {
                    if(u.getFechabaja()==null){
                    fechaBaja = validador.getInstance().obtenerFechaSistema();
                    u.setFechabaja(fechaBaja);
                    try {
                        controladorprovee.modificarProveedor(u);
                    } catch (Exception e) {
                        System.out.println("No pudoo modificar proveedor fecha baja" + e);
                    }
                    }else{
                         JOptionPane.showMessageDialog(this, "Este proveedor ya fue dado de baja en la fecha:" + u.getFechabaja() + " !", "Consulta Proveedor",  JOptionPane.WARNING_MESSAGE);;
                    }
                }
            }
            cargarTabla();
        }

    }
}//GEN-LAST:event_eliminarActionPerformed

////////////////////LISTAR OPERARIO///////////////////////////////////////
    private void cargarComboRazon() {
        try {
            listap = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de la lista de proveedores " + listap.size());
        } catch (Exception e) {
        }
        jComboBoxRazon.removeAllItems();
        for (int i = 0; i < listap.size(); i++) {
            Vector fila = new Vector();
            Proveedor prove = (Proveedor) listap.get(i);
            fila.add(prove.getRazonSocialProveedor());
            jComboBoxRazon.addItem(fila.get(0));
        }
    }

private void jButtonBuscarConActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarConActionPerformed
///////////////

    System.out.println("");
    Proveedor miprov = null;
    Object esteoperar = jComboBoxRazon.getSelectedItem();
    String nombrecuil = esteoperar.toString();
    System.out.println("nombre cuil " + nombrecuil);
    try {
        miprov = controladorprovee.buscarProveedorRazon(nombrecuil);
        System.out.println("mioperar " + miprov);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El proveedor ingresado no se ha encontrado.\n ", "Proveedor", JOptionPane.ERROR_MESSAGE);
    }

    if (miprov != null) {

        jTextFieldNombreListar.setText(miprov.getNombreProveedor());
        jTextFielCuit.setText(String.valueOf(miprov.getCuitProveedor()));
        jTextFieldtelefono.setText(String.valueOf(miprov.getTelefono1()));
        jTextFielapellido.setText(miprov.getApellidoProveedor());
        jTextFieldFechaAlta.setText(miprov.getFechaalta());
       
    }
}//GEN-LAST:event_jButtonBuscarConActionPerformed

/////////////////ALTA OPERARIO/////////////////////////////
//este da error porque devuelve nulo ya que no hay ninguna provincia seleccionada da nul pointer exception    public void mostrarCodigoPostal(String codigo) {
       
    
/////////////////LISTAR////////////////////
private void jComboBoxRazonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRazonActionPerformed
}//GEN-LAST:event_jComboBoxRazonActionPerformed

private void jComboBoxRazonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxRazonMousePressed
limpiarCampos();
cargarComboRazon();// TODO add your handling code here:
}//GEN-LAST:event_jComboBoxRazonMousePressed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
jPanel4.setVisible(true);    // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
jPanel5.setVisible(true);    // TODO add your handling code here:
BuscarProvBaja();
}//GEN-LAST:event_jButton2ActionPerformed
//////////////////LISTAR///////////////
//Ojo qeu no verifica bien el telefono. da error cuando se ingresa una letra.
    //razon, nroPrevSocial,  apellido, nombre, nroIB, nroInv, pais,  provincia,localidad, telefono1, telefono2, fechaAlta, fechaBaja

    private boolean verificar(String razon, String nroPrevSocial, String apellido, String nombre, String nroIB, String nroInv, String pais, String provincia, String localidad, String telefono1,  String direccion) {

        boolean ver = false;
        if (razon.equals("") || nroPrevSocial.equals("") || apellido.equals("") || nombre.equals("") || nroIB.equals("") || nroInv.equals("") || pais.equals("") || provincia.equals("") || localidad.equals("") || telefono1.equals("") || telefono2.equals("") || direccion.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor llene todos los campos!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetrasYNumerosYEspacios(razon)) {
            JOptionPane.showMessageDialog(this, "Apellido invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetrasYEspacios(apellido)) {
            JOptionPane.showMessageDialog(this, "Nombre invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneLetrasYEspacios(nombre)) {
            JOptionPane.showMessageDialog(this, "Nombre invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumerosYGuiones(nroIB)) {
            JOptionPane.showMessageDialog(this, "Número de Ingresos Brutos invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumerosYGuiones(nroInv)) {
            JOptionPane.showMessageDialog(this, "Número de Ingresos Brutos invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);


        } else if (!validador.getInstance().soloContieneLetrasYNumerosYEspacios(direccion)) {

            JOptionPane.showMessageDialog(this, "Dirección invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().esTelefonoValido(telefono1)) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para telefono1 es incorrecto!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().esTelefonoValido(telefono2)) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para telefono2 es incorrecto!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }
        return ver;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ButtBuscar;
    private javax.swing.JButton eliminar;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonBuscarCon;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JComboBox jComboBoxRazon;
    private javax.swing.JComboBox jComboBoxlocalidad;
    private javax.swing.JComboBox jComboBoxlocalidad1;
    private javax.swing.JComboBox jComboBoxpais;
    private javax.swing.JComboBox jComboBoxpais1;
    private javax.swing.JComboBox jComboBoxprovincia;
    private javax.swing.JComboBox jComboBoxprovincia1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelApellidoCon;
    private javax.swing.JLabel jLabelDireccionCon;
    private javax.swing.JLabel jLabelDniCon;
    private javax.swing.JLabel jLabelTelCon;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTablePB;
    private javax.swing.JTable jTableProveedores;
    private javax.swing.JTextField jTextFielCuit;
    private javax.swing.JTextField jTextFielapellido;
    private javax.swing.JTextField jTextFieldFechaAlta;
    private javax.swing.JTextField jTextFieldNombreListar;
    private javax.swing.JTextField jTextFieldUsuario2;
    private javax.swing.JTextField jTextFieldapellido;
    private javax.swing.JTextField jTextFieldapellido1;
    private javax.swing.JTextField jTextFieldcajaPrevision1;
    private javax.swing.JTextField jTextFieldcajavPrev;
    private javax.swing.JTextField jTextFieldcodigoPostal;
    private javax.swing.JTextField jTextFieldcodigoPostal1;
    private javax.swing.JTextField jTextFieldcuit;
    private javax.swing.JTextField jTextFieldcuit1;
    private javax.swing.JTextField jTextFielddireccion;
    private javax.swing.JTextField jTextFielddireccion1;
    private javax.swing.JTextField jTextFieldnombre;
    private javax.swing.JTextField jTextFieldnombre1;
    private javax.swing.JTextField jTextFieldnroIB;
    private javax.swing.JTextField jTextFieldnroIB1;
    private javax.swing.JTextField jTextFieldnroInv;
    private javax.swing.JTextField jTextFieldnroInv1;
    private javax.swing.JTextField jTextFieldrazon;
    private javax.swing.JTextField jTextFieldrazon1;
    private javax.swing.JTextField jTextFieldtelefono;
    private javax.swing.JTextField jTextFieldtelefono1;
    private javax.swing.JTextField jTextFieldtelefono2;
    private javax.swing.JTextField jTextFieldtelefono3;
    private javax.swing.JTextField jTextFieldtelefono4;
    private javax.swing.JButton modificar;
    // End of variables declaration//GEN-END:variables

    private boolean verificar(String cuit) {
        boolean ver = false;

        if (cuit.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor ingrese el cuil del operario!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYGuiones(cuit)) {
            JOptionPane.showMessageDialog(this, "Cuil incorrecto: Ingrese números y guiones para cuil!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!repetidoProveedor(cuit) == true) {
            JOptionPane.showMessageDialog(this, "Error el numero de cuil pertenece a otro operario !!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }

        return ver;
    }
    private boolean verificar2(String cuit) {
        boolean ver = false;

        if (cuit.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor ingrese el cuil del operario!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYGuiones(cuit)) {
            JOptionPane.showMessageDialog(this, "Cuil incorrecto: Ingrese números y guiones para cuil!!!", "Error", JOptionPane.ERROR_MESSAGE);
       // } else if (!repetidoProveedor(cuit) == true) {
        //    JOptionPane.showMessageDialog(this, "Error el numero de cuil pertenece a otro operario !!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }

        return ver;
    }


    private boolean repetidoProveedor(String cuit) {
        boolean estarepetido = false;
        Proveedor operarc = new Proveedor();
        try {
            operarc = controladorprovee.buscarProveedorCuit(cuit);
            estarepetido = false;
            System.out.println("Encontró el cuil en un operario");
        } catch (Exception e) {
            System.out.println("NO está repetido el cuil en otro operario");
            estarepetido = true;
        }
        return estarepetido;

    }


    private void rellenaCombo2(String pais) {
     Pais mipais = null;
   // Object estepais = jComboBoxpais.getSelectedItem();
    String nombrepais = pais;//nombre del pais
    try {
        mipais = controladorpais.buscarPaisNombre(nombrepais);
    } catch (Exception e) {
    }

    cargarComboProvincias(mipais.getIdpais());//donde las provincias que se carguen pertenezcan al pais seleccionado

   //  Provincia miprovincia = null;

  /*  String nombreprovincia = estaprovincia.toString();
    try {
        miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
    } catch (Exception e) {
    }
//Object estaprovincia = jComboBoxprovincia.getSelectedItem();*/
 //




            }
  private void rellenaCombo3(String provincia) {
      Provincia miprovincia = null;
// Object estaprovincia = jComboBoxprovincia.getSelectedItem();
    String nombreprovincia = provincia;
    try {
        miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
        cargarComboLocalidades(miprovincia.getIdprovincia());
    } catch (Exception e) {
    }

    /* Localidad mislocalidades = null;
    Object estalocalidad = jComboBoxlocalidad.getSelectedItem();
    System.out.println(estalocalidad.toString());
    try {
        mislocalidades = controladorlocal.buscarLocalidadNombre(estalocalidad.toString());
    } catch (Exception e) {
        System.out.println(e);
    }
    mostrarCodigoPostal(mislocalidades.getCodigopostal());*/
            }

  private void rellenaCombo4(String loc) {
               Localidad mislocalidades = null;
    Object estalocalidad = loc;
    String codigopostal = "";
    //System.out.println(estalocalidad.toString());
    try {
        mislocalidades = controladorlocal.buscarLocalidadNombre(estalocalidad.toString());
        codigopostal = mislocalidades.getCodigopostal();
         jTextFieldcodigoPostal.setText(codigopostal);
    } catch (Exception e) {
        System.out.println(e);
    }

            }


   private void rellenaCombo5(String pais) {
     Pais mipais1 = null;
   // Object estepais = jComboBoxpais.getSelectedItem();
    String nombrepais1 = pais;//nombre del pais
    try {
        mipais1 = controladorpais.buscarPaisNombre(nombrepais1);
    } catch (Exception e) {
    }

    cargarComboProvincias1(mipais1.getIdpais());//donde las provincias que se carguen pertenezcan al pais seleccionado

   //  Provincia miprovincia = null;

  /*  String nombreprovincia = estaprovincia.toString();
    try {
        miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
    } catch (Exception e) {
    }
//Object estaprovincia = jComboBoxprovincia.getSelectedItem();*/
 //




            }
  private void rellenaCombo6(String provincia) {
      Provincia miprovincia1 = null;
// Object estaprovincia = jComboBoxprovincia.getSelectedItem();
    String nombreprovincia1 = provincia;
    try {
        miprovincia1 = controladorprov.buscarProvinciaNombre(nombreprovincia1);
        cargarComboLocalidades1(miprovincia1.getIdprovincia());
    } catch (Exception e) {
    }

    /* Localidad mislocalidades = null;
    Object estalocalidad = jComboBoxlocalidad.getSelectedItem();
    System.out.println(estalocalidad.toString());
    try {
        mislocalidades = controladorlocal.buscarLocalidadNombre(estalocalidad.toString());
    } catch (Exception e) {
        System.out.println(e);
    }
    mostrarCodigoPostal(mislocalidades.getCodigopostal());*/
            }

  private void rellenaCombo7(String loc) {
               Localidad mislocalidades1 = null;
    Object estalocalidad1 = loc;
    String codigopostal1 = "";
    //System.out.println(estalocalidad.toString());
    try {
        mislocalidades1 = controladorlocal.buscarLocalidadNombre(estalocalidad1.toString());
        codigopostal1 = mislocalidades1.getCodigopostal();
         jTextFieldcodigoPostal1.setText(codigopostal1);
    } catch (Exception e) {
        System.out.println(e);
    }

            }

   

    private void cargarComboLocalidades1(int idprovincia) {

        Provincia estaprovincia = null;
        try {
            estaprovincia = controladorprov.buscarProvincia_X_idProvincia(idprovincia);
            System.out.println(estaprovincia.getNombreprovincia());
            listaloc = controladorlocal.buscarTodosLocalidad();
        } catch (Exception e) {
        }
        jComboBoxlocalidad1.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {//para todas las localidades
            Vector fila = new Vector();
            Localidad milocalidad = (Localidad) listaloc.get(i);
            if (milocalidad.getProvincia().equals(estaprovincia)) {
                fila.add(milocalidad.getNombrelocalidad());
                jComboBoxlocalidad1.addItem(fila.get(0));
            }
        }
    }

    private void cargarComboProvincias1(int idpais) {

        Pais estepais = null;
        try {
            estepais = controladorpais.buscarPais_X_idPais(idpais);//el qeu traia seleccionado
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia1.removeAllItems();
        for (int j = 0; j < listaprov.size(); j++) {//por cada una de todas las provincias
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(j);
            if (provincia.getPais().equals(estepais)) {
                fila.add(provincia.getNombreprovincia());
                jComboBoxprovincia1.addItem(fila.get(0));


            }
        }

    }

    private void BuscarProvBaja() {
         String[] encabezados = new String[6];
        encabezados[0] = "Razón Social";
        encabezados[1] = "Apellido";
        encabezados[2] = "Nombre";
        encabezados[3] = "Nro I.N.V";
        encabezados[4] = "Telefono";
        encabezados[5] = "Fecha Baja";

        tableModel = new TablaPersonalizada(encabezados);
        jTablePB.setModel(tableModel);

        try {
            listapbaja = controladorprovee.buscarProveedorBaja();
            System.out.println("tamaño de listaobaja" + listapbaja);

            for (int i = 0; i < listapbaja.size(); i++) {

                Proveedor p = (Proveedor) listapbaja.get(i);
                Vector fila = new Vector();
                fila.add(p.getRazonSocialProveedor());
                fila.add(p.getApellidoProveedor());
                fila.add(p.getNombreProveedor());
                 fila.add(p.getNumeroInvProveedor());
                fila.add(p.getTelefono1());
               
                fila.add(p.getFechabaja());
                tableModel.addRow(fila);
            }

        } catch (Exception e) {
        }
    }
    


}
